<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Clubvideo extends Model
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'title','cover_image','video_url','club_id'
    ];
    
    public function keytodata($keyname){
        return collect($keyname)->map(function($key){
            if(  !is_string($this->$key) && !is_int($this->$key)){
                if(  $this->$key  instanceof Carbon){
                    return [$key=>$this->$key->toFormattedDateString()];
                }
                else{
                    return [$key=>$this->$key->pluck('name')];
                }

            }

            return [$key=>$this->$key];
        })->collapse()->toArray();

      }   

}
